﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Glossary;

namespace StudentSolution
{
    public partial class Glossblad : Form
    {
        private string[] _information;
        private List<Word> _exam;

        public Glossblad(List<Word> exam, string[] information)
        {
            this._information = information;
            this._exam = exam;

            InitializeComponent();
            FillTheGrid();
        }

        private void FillTheGrid()
        {
            string answer = "";
            foreach (Word w in _exam)
            {
                answer = (w.Correct) ? "Rätt" : "Fel";
                DataGridViewRow newRow = new DataGridViewRow();
                examOverview.Rows.Add(w.Foreign, w.Swedish, w.Answer, answer);
            }

            for (int i = 0; i < examOverview.Rows.Count; i++)
                examOverview.Rows[i].ReadOnly = true;

            nameInfo.Text = String.Format("{0} {1}",_information[1], _information[2]);
            streetInfo.Text = String.Format("{0}", _information[3]);
            cityInfo.Text = String.Format("{0} {1}", _information[4], _information[5]);

            wordCountLabel.Text = String.Format("{0} / {1}",_information[6],_information[7]);

            try
            {
                switch ((Languages)int.Parse(_information[0]))
                {
                    case Languages.English:
                        languageLabel.Text = "Engelska";
                        break;
                    case Languages.Spanish:
                        languageLabel.Text = "Spanska";
                        break;
                    case Languages.German:
                        languageLabel.Text = "Tyska";
                        break;
                }
            }
            catch (Exception)
            {
                languageLabel.Text = "Språk hittades ej.";
            }
        }

        private void exitButton_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
